from django import forms
from django.forms import widgets
from django.core.exceptions import ValidationError
from django_summernote.fields import SummernoteTextField
from mdeditor.fields import MDTextField

from  hcw_models.models import *

class ArticleForm(forms.ModelForm):
    class Meta:
        model=Article
        fields=["title","excerpt","content","Class","status"]

class commentForm(forms.ModelForm):

    class Meta:
        model=comment
        fields=["content"]



class MyUserForm(forms.ModelForm):
    class Meta:
        model=MyUser
        fields=["phone_number","img","userinfo"]
        widgets = {
            'phone_number': forms.widgets.TextInput(attrs={'class':  "form-control"}),
            'userinfo': forms.widgets.Textarea(attrs={'class':  "form-control"})
          
        }



# class UserinfoForm(forms.ModelForm):
#     class Meta:
#         model=MyUser
#         fields=["username","first","last_name","img"]
# class UserinfoForm(forms.Form):
#     username = forms.CharField(
#         # min_length=8,
#         label="用户名",
#         # initial="张三",
#         widget=widgets.TextInput(attrs={'class':'form-control'})
#     )
#     img = forms.ImageField(verbose_name='文章图片',upload_to="article_img/%Y/%m/%d/",label="上传头像")

    # img = models.ImageField( label="文件上传",widget=widgets.FileInput(attrs={'class':'form-control'})

    # pwd = fo

    # pwd = forms.CharField(min_length=6, label="密码")
    # def clean(self):
    #     print ("==========",self.request)

    #     cleaned_data = super(SomeAdminForm, self).clean()
    #     logged_in_email = self.request.user.email #voila
    #     print ("==========",self.request)
    #     if logged_in_email in ['abc@abc.com']:
    #         raise ValidationError("Please behave, you are not authorised.....Thank you!!")
    #     return cleaned_data